﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.IO;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using System.Collections.Generic;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class MatchInstructions_New : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.MatchInstructions_pageTitle;
            
            string version = "";
            try { version = ConfigurationManager.AppSettings["version"]; }
            catch { version = "999.0.0.0"; }

            MatchInstructionsLinkLiteral.Text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"MatchInstructions.css?v=" + version + "\" />";
            JavascripLinkLiteral.Text = "<script type=\"text/javascript\" src=\"JS/MatchInstructions_v2.js?v=" + version + "\"></script>";
            JavaSubLinkLiteral.Text = "<script src=\"JS/MatchInstructions_Sub_v2.js?v=" + version + "\" type=\"text/javascript\"></script>";


            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                Response.Redirect("~/Default.aspx");

            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            OnlineUser ou = (OnlineUser)Session["User"];
            
            string MatchToLoad;

            if (ou.TeamId == "Null")
                Response.Redirect("~/GeneralMessage.aspx?MessageString=M74ggdizz5wfeh");


            if (Request.QueryString["MatchId"] != null)
                MatchIdHiddenField.Value = Request.QueryString["MatchId"];
            else
                Response.Redirect("~/TeamHomePage.aspx"); 
            
            bool IsNTMatch = GND.ReadNivdalBoolData("MatchId", "Nivdal_IsMatchNT", MatchIdHiddenField.Value);

            TeamIdHiddenField.Value = IsNTMatch ? ou.NationalTeamCoach : ou.TeamId;


            // Redirection to basic instructions.
            BasicInstructionsHyperLink.NavigateUrl = "MatchInstructionsStep1.aspx?MatchId=" + MatchIdHiddenField.Value;

            // dealing with page title and Page name label
            string PageTitle = GND.ReadNivdalStringData("@MatchId", "Nivdal_GetMatchTitleString", MatchIdHiddenField.Value);
            //this.Title = PageTitle + " - Nivdal.com!";
            this.PageNameLabel.Text = PageTitle + " " + Resources.Resource.MatchInstructions_PageNameLabel;
            
            // Hide Master's Info panel
            (Master.Master.FindControl("MasterInfoPanel") as Panel).Visible = false;

            if (!IsPostBack)
            {
                UserIdHiddenField.Value = ou.UserId;
                LanguageHiddenField.Value = ou.Language;

                MatchToLoad = MatchIdHiddenField.Value;
                if (Request.QueryString["LoadMatch"] != null)
                {
                    MatchToLoad = Request.QueryString["LoadMatch"];
                }
                if (!GND.ReadNivdalBoolData("@UserId", "@MatchId", "Nivdal_ShouldUserGiveInstructionsToMatch", ou.UserId, MatchIdHiddenField.Value))
                    Response.Redirect("GeneralMessage.aspx?MessageString=ko3ATUOTLOB");

                PlayersDataSourse.SelectParameters.Add("UserId", ou.UserId);
                PlayersDataSourse.SelectParameters.Add("MatchId", MatchIdHiddenField.Value);
                PreviousMatchesDataSourse.SelectParameters.Add("TeamId", TeamIdHiddenField.Value);
                PreviousMatchesDataSourse.SelectParameters.Add("MatchId", MatchIdHiddenField.Value);
                PlayersDDLDataSource.SelectParameters.Add("TeamId", TeamIdHiddenField.Value);
                PlayersDDLDataSource.SelectParameters.Add("MatchId", MatchIdHiddenField.Value);

                if (PlayersGridView.Rows.Count > 0)
                {
                    PlayersGridView.UseAccessibleHeader = true;
                    PlayersGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                }

                NumPlayersHiddenField.Value = "0";
                if (GND.ReadNivdalBoolData("@MatchId", "Nivdal_ShouldPenaltyTakersBeShown", MatchIdHiddenField.Value))
                {
                    this.PenaltiesVisibleHiddenField.Value = "1";
                }
                else
                {
                    this.PenaltiesVisibleHiddenField.Value = "0";
                }
                LoadOrders(MatchToLoad);
                LoadSubstitutions(MatchToLoad);
                LoadPreviousMatchInstructionsPanel.Visible = ou.IsPremium;
                LoadDefaultInstructionTypes();

                // fix strings length:
                if (SetPiecesTakerLabel.Text.Length > 14)
                {
                    SetPiecesTakerLabel.ToolTip = SetPiecesTakerLabel.Text;
                    SetPiecesTakerLabel.Text = SetPiecesTakerLabel.Text.Substring(0, 14);                    
                }
                if (CaptainTitleLabel.Text.Length > 15)
                {
                    CaptainTitleLabel.ToolTip = CaptainTitleLabel.Text;
                    CaptainTitleLabel.Text = CaptainTitleLabel.Text.Substring(0, 15);
                }
                if (ShowSubstitutionButton.Text.Length > 20)
                {
                    ShowSubstitutionButton.ToolTip = ShowSubstitutionButton.Text;
                    ShowSubstitutionButton.Text = ShowSubstitutionButton.Text.Substring(0, 20) + "...";
                }
                if (ShowPlayerChangeButton.Text.Length > 20)
                {
                    ShowPlayerChangeButton.ToolTip = ShowPlayerChangeButton.Text;
                    ShowPlayerChangeButton.Text = ShowPlayerChangeButton.Text.Substring(0, 20) + "...";
                }
                if (ShowTeamChangeButton.Text.Length > 20)
                {
                    ShowTeamChangeButton.ToolTip = ShowTeamChangeButton.Text;
                    ShowTeamChangeButton.Text = ShowTeamChangeButton.Text.Substring(0, 20) + "...";
                }
                if (ShowPenaltyTakersButton.Text.Length > 20)
                {
                    ShowPenaltyTakersButton.ToolTip = ShowPenaltyTakersButton.Text;
                    ShowPenaltyTakersButton.Text = ShowPenaltyTakersButton.Text.Substring(0, 20) + "...";
                }
                if (ChooseAttributesToShowLabel.Text.Length > 30)
                {
                    ChooseAttributesToShowLabel.ToolTip = ChooseAttributesToShowLabel.Text;
                    ChooseAttributesToShowLabel.Text = ChooseAttributesToShowLabel.Text.Substring(0, 30) + "...";
                }
                if (LoadPreviousMatchTitlelabel.Text.Length > 50)
                {
                    LoadPreviousMatchTitlelabel.ToolTip = LoadPreviousMatchTitlelabel.Text;
                    LoadPreviousMatchTitlelabel.Text = LoadPreviousMatchTitlelabel.Text.Substring(0, 50) + "...";
                }
            }

            
        }

        protected void Page_PreRender(Object sender, EventArgs e)
        {
            ContentDirection Dir = (Master.Master.FindControl("DirectionPanel") as Panel).Direction;
            if (Dir == ContentDirection.LeftToRight)
            {
                DirectionHiddenField.Value = "left";
            }
            else
            {
                DirectionHiddenField.Value = "right";
            }

        }

        private void LoadDefaultInstructionTypes()
        {
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            OnlineUser ou = (OnlineUser)Session["User"];

            string Type = GND.ReadNivdalIntData("MatchId", "Nivdal_GetMatchTypeById", MatchIdHiddenField.Value);
            bool IsNT = GND.ReadNivdalBoolData("MatchId", "Nivdal_IsMatchNT", MatchIdHiddenField.Value);
            SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeAll, "0"));

            if (!IsNT) switch (Type)
            { 
                case "1":
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeLeague, "1"));
                    break;
                case "2":    
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeCup, "2"));
                    break;
                case "3":                    
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeIntCup, "3"));
                    break;
                case "4":                
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeFriendly, "4"));
                    break;
                case "6":
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeFriendly, "4"));
                    break;
                default: break;
            }
            else switch (Type)
            {
                case "1":
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeGroupStage, "1"));
                    break;
                case "2":
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypePlayoffStage, "2"));
                    break;
                case "4":
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeFriendly, "4"));
                    break;
                case "6":
                    SaveDefaultTypeDDL.Items.Add(new ListItem(Resources.Resource.GameInstructions_MatchTypeFriendly, "4"));
                    break;
                default: break;
            }

        }

        protected void LoadPreviousInstructions(object sender, EventArgs e)
        {
            string MatchId = MatchIdHiddenField.Value;
            string LoadMatch = PreviousMatchesDDL.SelectedValue;
            Response.Redirect("MatchInstructions_New.aspx?MatchId=" + MatchId + "&LoadMatch=" + LoadMatch);
        }


        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }

        protected string NumberStringCorrected(object shirtNum)
        {
            string ReturnValue = "0";
            int Value = 0;
            try
            {
                ReturnValue = shirtNum.ToString();
                Value = int.Parse(shirtNum.ToString());
            }
            catch { return ("101"); }
            if (Value < 10)
                ReturnValue = "0" + ReturnValue.ToString();
            if (Value < 100)
                ReturnValue = "0" + ReturnValue.ToString();
            return (ReturnValue);
        }

        protected ContentDirection GetDirection()
        {
            return ((Master.Master.FindControl("DirectionPanel") as Panel).Direction);
        }
        protected string GetAlinment()
        {
            string alinment = "text-align:left;";
            ContentDirection Dir = (Master.Master.FindControl("DirectionPanel") as Panel).Direction;
            if (Dir == ContentDirection.RightToLeft)
            {
                alinment = "text-align:right;";
            }
            return alinment;
        }

        #region PutPlayerOnPitch

        private int FindOpenSubPosition()
        {
            int ReturnValue = 0;

            if (Sub1PlayerIdHiddenField.Value == "0")
                ReturnValue = 1;
            else if (Sub2PlayerIdHiddenField.Value == "0")
                ReturnValue = 2;
            else if (Sub3PlayerIdHiddenField.Value == "0")
                ReturnValue = 3;
            else if (Sub4PlayerIdHiddenField.Value == "0")
                ReturnValue = 4;
            else if (Sub5PlayerIdHiddenField.Value == "0")
                ReturnValue = 5;

            return ReturnValue;
        }

        private void PutSubOnPitch(string PlayerId, string Position, string Name)
        {
            if (PlayerId != "0" && PlayerId != null)
            {
                int SubPosition = FindOpenSubPosition();
                switch (SubPosition)
                {
                    case 1:
                        Sub1PlayerIdHiddenField.Value = PlayerId;
                        Sub1PositionsRadioButtonList.SelectedValue = Position;
                        Sub1PositionsRadioButtonListLabel.Text = GetPositionName(Position);
                        Sub1PlayerName.Text = Name;
                        break;
                    case 2:
                        Sub2PlayerIdHiddenField.Value = PlayerId;
                        Sub2PositionsRadioButtonList.SelectedValue = Position;
                        Sub2PositionsRadioButtonListLabel.Text = GetPositionName(Position);
                        Sub2PlayerName.Text = Name;
                        break;
                    case 3:
                        Sub3PlayerIdHiddenField.Value = PlayerId;
                        Sub3PositionsRadioButtonList.SelectedValue = Position;
                        Sub3PositionsRadioButtonListLabel.Text = GetPositionName(Position);
                        Sub3PlayerName.Text = Name;
                        break;
                    case 4:
                        Sub4PlayerIdHiddenField.Value = PlayerId;
                        Sub4PositionsRadioButtonList.SelectedValue = Position;
                        Sub4PositionsRadioButtonListLabel.Text = GetPositionName(Position);
                        Sub4PlayerName.Text = Name;
                        break;
                    case 5:
                        Sub5PlayerIdHiddenField.Value = PlayerId;
                        Sub5PositionsRadioButtonList.SelectedValue = Position;
                        Sub5PositionsRadioButtonListLabel.Text = GetPositionName(Position);
                        Sub5PlayerName.Text = Name;
                        break;
                    default:
                        break;
                }
            }
        }

        //private string GetInstructionString(string Instruction)
        //{
        //    string ReturnValue = "";
        //    GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();

        //    ReturnValue = GND.ReadNivdalStringData("

        //    return ReturnValue;
        //}

        private string GetInstructionName(string Instruction)
        {
            string Language = LanguageHiddenField.Value;
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            string ReturnValue = GND.ReadNivdalStringData("InstructionId", "Language", "Nivdal_GetInstructionStringByIdProc", Instruction, Language);

            return ReturnValue;
        }

        private string GetPreferredActionName(string PreferredAction)
        {
            string Language = LanguageHiddenField.Value;
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            string ReturnValue = GND.ReadNivdalStringData("PreferredActionId", "Language", "Nivdal_GetPreferredActionStringByIdProc", PreferredAction, Language);

            return ReturnValue;
        }

        private string GetPositionName(string Position)
        {
            string Language = LanguageHiddenField.Value;
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();

            string ReturnValue = GND.ReadNivdalStringData("PositionId", "Language", "Nivdal_GetPositionStringByIdProc", Position, Language);

            return ReturnValue;
        }



        private void PutPlayerOnPitch(string PlayerId, string Position, string PreferredAction, string Instruction)
        {
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            string PlayerName = GND.ReadNivdalStringData("PlayerId", "Nivdal_GetPlayerShortNameById", PlayerId);

            if (PlayerId != "0" && PlayerId != null)
            {
                switch (Position)
                {
                    case "1":
                        KeeperPlayerIdHiddenField.Value = PlayerId;
                        KeeperPlayerName.Text = PlayerName;
                        break;

                    case "2":
                        LeftDefencePlayerIdHiddenField.Value = PlayerId;
                        LeftDefencePreferredActionHiddenField.Value = PreferredAction;
                        LeftDefenceInstructionHiddenField.Value = Instruction;
                        LeftDefencePlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "3":
                        LeftCenterDefencePlayerIdHiddenField.Value = PlayerId;
                        LeftCenterDefencePreferredActionHiddenField.Value = PreferredAction;
                        LeftCenterDefenceInstructionHiddenField.Value = Instruction;
                        LeftCenterDefencePlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "4":
                        CenterDefencePlayerIdHiddenField.Value = PlayerId;
                        CenterDefencePreferredActionHiddenField.Value = PreferredAction;
                        CenterDefenceInstructionHiddenField.Value = Instruction;
                        CenterDefencePlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "5":
                        RightCenterDefencePlayerIdHiddenField.Value = PlayerId;
                        RightCenterDefencePreferredActionHiddenField.Value = PreferredAction;
                        RightCenterDefenceInstructionHiddenField.Value = Instruction;
                        RightCenterDefencePlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "6":
                        RightDefencePlayerIdHiddenField.Value = PlayerId;
                        RightDefencePreferredActionHiddenField.Value = PreferredAction;
                        RightDefenceInstructionHiddenField.Value = Instruction;
                        RightDefencePlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "7":
                        LeftMidfieldPlayerIdHiddenField.Value = PlayerId;
                        LeftMidfieldPreferredActionHiddenField.Value = PreferredAction;
                        LeftMidfieldInstructionHiddenField.Value = Instruction;
                        LeftMidfieldPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "8":
                        LeftCenterMidfieldPlayerIdHiddenField.Value = PlayerId;
                        LeftCenterMidfieldPreferredActionHiddenField.Value = PreferredAction;
                        LeftCenterMidfieldInstructionHiddenField.Value = Instruction;
                        LeftCenterMidfieldPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "9":
                        CenterMidfieldPlayerIdHiddenField.Value = PlayerId;
                        CenterMidfieldPreferredActionHiddenField.Value = PreferredAction;
                        CenterMidfieldInstructionHiddenField.Value = Instruction;
                        CenterMidfieldPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "10":
                        RightCenterMidfieldPlayerIdHiddenField.Value = PlayerId;
                        RightCenterMidfieldPreferredActionHiddenField.Value = PreferredAction;
                        RightCenterMidfieldInstructionHiddenField.Value = Instruction;
                        RightCenterMidfieldPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "11":
                        RightMidfieldPlayerIdHiddenField.Value = PlayerId;
                        RightMidfieldPreferredActionHiddenField.Value = PreferredAction;
                        RightMidfieldInstructionHiddenField.Value = Instruction;
                        RightMidfieldPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "12":
                        LeftAttackPlayerIdHiddenField.Value = PlayerId;
                        LeftAttackPreferredActionHiddenField.Value = PreferredAction;
                        LeftAttackInstructionHiddenField.Value = Instruction;
                        LeftAttackPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "13":
                        LeftCenterAttackPlayerIdHiddenField.Value = PlayerId;
                        LeftCenterAttackPreferredActionHiddenField.Value = PreferredAction;
                        LeftCenterAttackInstructionHiddenField.Value = Instruction;
                        LeftCenterAttackPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "14":
                        CenterAttackPlayerIdHiddenField.Value = PlayerId;
                        CenterAttackPreferredActionHiddenField.Value = PreferredAction;
                        CenterAttackInstructionHiddenField.Value = Instruction;
                        CenterAttackPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "15":
                        RightCenterAttackPlayerIdHiddenField.Value = PlayerId;
                        RightCenterAttackPreferredActionHiddenField.Value = PreferredAction;
                        RightCenterAttackInstructionHiddenField.Value = Instruction;
                        RightCenterAttackPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "16":
                        RightAttackPlayerIdHiddenField.Value = PlayerId;
                        RightAttackPreferredActionHiddenField.Value = PreferredAction;
                        RightAttackInstructionHiddenField.Value = Instruction;
                        RightAttackPlayerName.Text = PlayerName;
                        NumPlayersHiddenField.Value = ((int.Parse(NumPlayersHiddenField.Value)) + 1).ToString();
                        break;

                    case "17":
                        PutSubOnPitch(PlayerId, Position, PlayerName);
                        break;

                    case "18":
                        PutSubOnPitch(PlayerId, Position, PlayerName);
                        break;

                    case "19":
                        PutSubOnPitch(PlayerId, Position, PlayerName);
                        break;

                    case "20":
                        PutSubOnPitch(PlayerId, Position, PlayerName);
                        break;
                }
            }
        }

        #endregion PutPlayerOnPitch

        protected void RadioButtonListDataBound(object sender, EventArgs e)
        {
            RadioButtonList list = (RadioButtonList)sender;
            string listId = list.ClientID;

            foreach (ListItem item in list.Items)
            {
                item.Attributes.Add("onclick", "javascript:ListItemClick('" + listId + "', '" + item.Text + "');");
            }
        }

        private void ClearAllPlayerIds()
        {
            LeftAttackPlayerIdHiddenField.Value = "0";
            LeftAttackPreferredActionHiddenField.Value = "2";
            LeftAttackInstructionHiddenField.Value = "2";
            LeftAttackInjuredHiddenField.Value = "0";

            LeftCenterAttackPlayerIdHiddenField.Value = "0";
            LeftCenterAttackInstructionHiddenField.Value = "2";
            LeftCenterAttackPreferredActionHiddenField.Value = "2";
            LeftCenterAttackInjuredHiddenField.Value = "0";

            CenterAttackPlayerIdHiddenField.Value = "0";
            CenterAttackInstructionHiddenField.Value = "2";
            CenterAttackPreferredActionHiddenField.Value = "2";
            CenterAttackInjuredHiddenField.Value = "0";

            RightCenterAttackPlayerIdHiddenField.Value = "0";
            RightCenterAttackInstructionHiddenField.Value = "2";
            RightCenterAttackPreferredActionHiddenField.Value = "2";
            RightCenterAttackInjuredHiddenField.Value = "0";

            RightAttackPlayerIdHiddenField.Value = "0";
            RightAttackInstructionHiddenField.Value = "2";
            RightAttackPreferredActionHiddenField.Value = "2";
            RightAttackInjuredHiddenField.Value = "0";

            LeftMidfieldPlayerIdHiddenField.Value = "0";
            LeftMidfieldInstructionHiddenField.Value = "2";
            LeftMidfieldPreferredActionHiddenField.Value = "2";
            LeftMidfieldInjuredHiddenField.Value = "0";

            LeftCenterMidfieldPlayerIdHiddenField.Value = "0";
            LeftCenterMidfieldInstructionHiddenField.Value = "2";
            LeftCenterMidfieldPreferredActionHiddenField.Value = "2";
            LeftCenterMidfieldInjuredHiddenField.Value = "0";

            CenterMidfieldPlayerIdHiddenField.Value = "0";
            CenterMidfieldInstructionHiddenField.Value = "2";
            CenterMidfieldPreferredActionHiddenField.Value = "2";
            CenterMidfieldInjuredHiddenField.Value = "0";

            RightCenterMidfieldPlayerIdHiddenField.Value = "0";
            RightCenterMidfieldInstructionHiddenField.Value = "2";
            RightCenterMidfieldPreferredActionHiddenField.Value = "2";
            RightCenterMidfieldInjuredHiddenField.Value = "0";

            RightMidfieldPlayerIdHiddenField.Value = "0";
            RightMidfieldInstructionHiddenField.Value = "2";
            RightMidfieldPreferredActionHiddenField.Value = "2";
            RightMidfieldInjuredHiddenField.Value = "0";

            LeftDefencePlayerIdHiddenField.Value = "0";
            LeftDefenceInstructionHiddenField.Value = "2";
            LeftDefencePreferredActionHiddenField.Value = "2";
            LeftDefenceInjuredHiddenField.Value = "0";

            LeftCenterDefencePlayerIdHiddenField.Value = "0";
            LeftCenterDefenceInstructionHiddenField.Value = "2";
            LeftCenterDefencePreferredActionHiddenField.Value = "2";
            LeftCenterDefenceInjuredHiddenField.Value = "0";

            CenterDefencePlayerIdHiddenField.Value = "0";
            CenterDefenceInstructionHiddenField.Value = "2";
            CenterDefencePreferredActionHiddenField.Value = "2";
            CenterDefenceInjuredHiddenField.Value = "0";

            RightCenterDefencePlayerIdHiddenField.Value = "0";
            RightCenterDefenceInstructionHiddenField.Value = "2";
            RightCenterDefencePreferredActionHiddenField.Value = "2";
            RightCenterDefenceInjuredHiddenField.Value = "0";

            RightDefencePlayerIdHiddenField.Value = "0";
            RightDefenceInstructionHiddenField.Value = "2";
            RightDefencePreferredActionHiddenField.Value = "2";
            RightDefenceInjuredHiddenField.Value = "0";

            KeeperPlayerIdHiddenField.Value = "0";
            KeeperInjuredHiddenField.Value = "0";

            Sub1PlayerIdHiddenField.Value = "0";
            Sub1PositionsRadioButtonList.ClearSelection();
            Sub1PlayerName.Text = "";

            Sub2PlayerIdHiddenField.Value = "0";
            Sub2PositionsRadioButtonList.ClearSelection();
            Sub2PlayerName.Text = "";

            Sub3PlayerIdHiddenField.Value = "0";
            Sub3PositionsRadioButtonList.ClearSelection();
            Sub3PlayerName.Text = "";

            Sub4PlayerIdHiddenField.Value = "0";
            Sub4PositionsRadioButtonList.ClearSelection();
            Sub4PlayerName.Text = "";

            Sub5PlayerIdHiddenField.Value = "0";
            Sub5PositionsRadioButtonList.ClearSelection();
            Sub5PlayerName.Text = "";

            CaptainHiddenField.Value = "0";
            SetPiecesTakerHiddenField.Value = "0";
        }


        protected void LoadOrders(string MatchId)
        {
            ClearAllPlayerIds();

            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();

            #region define sql parameters

            string conn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            using (System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(conn))
            {

                System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();
                dbCommand.CommandText = "Nivdal_GetCurrentGameInstructionsOutput";
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Connection = dbConnection;

                SqlParameter dbParam_UserId = new SqlParameter();
                dbParam_UserId.ParameterName = "@UserId";
                dbParam_UserId.Value = UserIdHiddenField.Value;
                dbParam_UserId.DbType = DbType.String;
                dbCommand.Parameters.Add(dbParam_UserId);

                SqlParameter dbParam_MatchId = new SqlParameter();
                dbParam_MatchId.ParameterName = "@MatchId";
                dbParam_MatchId.Value = MatchId;
                dbParam_MatchId.DbType = DbType.String;
                dbCommand.Parameters.Add(dbParam_MatchId);

                SqlParameter dbParam_PlayerId1 = new SqlParameter();
                dbParam_PlayerId1.ParameterName = "@PlayerId1";
                dbParam_PlayerId1.Value = "";
                dbParam_PlayerId1.DbType = DbType.Decimal;
                dbParam_PlayerId1.Direction = ParameterDirection.Output;
                dbParam_PlayerId1.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId1);

                SqlParameter dbParam_PlayerId2 = new SqlParameter();
                dbParam_PlayerId2.ParameterName = "@PlayerId2";
                dbParam_PlayerId2.Value = "";
                dbParam_PlayerId2.DbType = DbType.Decimal;
                dbParam_PlayerId2.Direction = ParameterDirection.Output;
                dbParam_PlayerId2.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId2);

                SqlParameter dbParam_PlayerId3 = new SqlParameter();
                dbParam_PlayerId3.ParameterName = "@PlayerId3";
                dbParam_PlayerId3.Value = "";
                dbParam_PlayerId3.DbType = DbType.Decimal;
                dbParam_PlayerId3.Direction = ParameterDirection.Output;
                dbParam_PlayerId3.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId3);

                SqlParameter dbParam_PlayerId4 = new SqlParameter();
                dbParam_PlayerId4.ParameterName = "@PlayerId4";
                dbParam_PlayerId4.Value = "";
                dbParam_PlayerId4.DbType = DbType.Decimal;
                dbParam_PlayerId4.Direction = ParameterDirection.Output;
                dbParam_PlayerId4.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId4);

                SqlParameter dbParam_PlayerId5 = new SqlParameter();
                dbParam_PlayerId5.ParameterName = "@PlayerId5";
                dbParam_PlayerId5.Value = "";
                dbParam_PlayerId5.DbType = DbType.Decimal;
                dbParam_PlayerId5.Direction = ParameterDirection.Output;
                dbParam_PlayerId5.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId5);

                SqlParameter dbParam_PlayerId6 = new SqlParameter();
                dbParam_PlayerId6.ParameterName = "@PlayerId6";
                dbParam_PlayerId6.Value = "";
                dbParam_PlayerId6.DbType = DbType.Decimal;
                dbParam_PlayerId6.Direction = ParameterDirection.Output;
                dbParam_PlayerId6.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId6);

                SqlParameter dbParam_PlayerId7 = new SqlParameter();
                dbParam_PlayerId7.ParameterName = "@PlayerId7";
                dbParam_PlayerId7.Value = "";
                dbParam_PlayerId7.DbType = DbType.Decimal;
                dbParam_PlayerId7.Direction = ParameterDirection.Output;
                dbParam_PlayerId7.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId7);

                SqlParameter dbParam_PlayerId8 = new SqlParameter();
                dbParam_PlayerId8.ParameterName = "@PlayerId8";
                dbParam_PlayerId8.Value = "";
                dbParam_PlayerId8.DbType = DbType.Decimal;
                dbParam_PlayerId8.Direction = ParameterDirection.Output;
                dbParam_PlayerId8.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId8);

                SqlParameter dbParam_PlayerId9 = new SqlParameter();
                dbParam_PlayerId9.ParameterName = "@PlayerId9";
                dbParam_PlayerId9.Value = "";
                dbParam_PlayerId9.DbType = DbType.Decimal;
                dbParam_PlayerId9.Direction = ParameterDirection.Output;
                dbParam_PlayerId9.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId9);

                SqlParameter dbParam_PlayerId10 = new SqlParameter();
                dbParam_PlayerId10.ParameterName = "@PlayerId10";
                dbParam_PlayerId10.Value = "";
                dbParam_PlayerId10.DbType = DbType.Decimal;
                dbParam_PlayerId10.Direction = ParameterDirection.Output;
                dbParam_PlayerId10.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId10);

                SqlParameter dbParam_PlayerId11 = new SqlParameter();
                dbParam_PlayerId11.ParameterName = "@PlayerId11";
                dbParam_PlayerId11.Value = "";
                dbParam_PlayerId11.DbType = DbType.Decimal;
                dbParam_PlayerId11.Direction = ParameterDirection.Output;
                dbParam_PlayerId11.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId11);

                SqlParameter dbParam_PlayerId12 = new SqlParameter();
                dbParam_PlayerId12.ParameterName = "@PlayerId12";
                dbParam_PlayerId12.Value = "";
                dbParam_PlayerId12.DbType = DbType.Decimal;
                dbParam_PlayerId12.Direction = ParameterDirection.Output;
                dbParam_PlayerId12.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId12);

                SqlParameter dbParam_PlayerId13 = new SqlParameter();
                dbParam_PlayerId13.ParameterName = "@PlayerId13";
                dbParam_PlayerId13.Value = "";
                dbParam_PlayerId13.DbType = DbType.Decimal;
                dbParam_PlayerId13.Direction = ParameterDirection.Output;
                dbParam_PlayerId13.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId13);

                SqlParameter dbParam_PlayerId14 = new SqlParameter();
                dbParam_PlayerId14.ParameterName = "@PlayerId14";
                dbParam_PlayerId14.Value = "";
                dbParam_PlayerId14.DbType = DbType.Decimal;
                dbParam_PlayerId14.Direction = ParameterDirection.Output;
                dbParam_PlayerId14.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId14);

                SqlParameter dbParam_PlayerId15 = new SqlParameter();
                dbParam_PlayerId15.ParameterName = "@PlayerId15";
                dbParam_PlayerId15.Value = "";
                dbParam_PlayerId15.DbType = DbType.Decimal;
                dbParam_PlayerId15.Direction = ParameterDirection.Output;
                dbParam_PlayerId15.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId15);

                SqlParameter dbParam_PlayerId16 = new SqlParameter();
                dbParam_PlayerId16.ParameterName = "@PlayerId16";
                dbParam_PlayerId16.Value = "";
                dbParam_PlayerId16.DbType = DbType.Decimal;
                dbParam_PlayerId16.Direction = ParameterDirection.Output;
                dbParam_PlayerId16.Size = 12;
                dbCommand.Parameters.Add(dbParam_PlayerId16);

                SqlParameter dbParam_PenaltyId1 = new SqlParameter();
                dbParam_PenaltyId1.ParameterName = "@Penalty1Taker";
                dbParam_PenaltyId1.Value = "";
                dbParam_PenaltyId1.DbType = DbType.Decimal;
                dbParam_PenaltyId1.Direction = ParameterDirection.Output;
                dbParam_PenaltyId1.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId1);

                SqlParameter dbParam_PenaltyId2 = new SqlParameter();
                dbParam_PenaltyId2.ParameterName = "@Penalty2Taker";
                dbParam_PenaltyId2.Value = "";
                dbParam_PenaltyId2.DbType = DbType.Decimal;
                dbParam_PenaltyId2.Direction = ParameterDirection.Output;
                dbParam_PenaltyId2.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId2);

                SqlParameter dbParam_PenaltyId3 = new SqlParameter();
                dbParam_PenaltyId3.ParameterName = "@Penalty3Taker";
                dbParam_PenaltyId3.Value = "";
                dbParam_PenaltyId3.DbType = DbType.Decimal;
                dbParam_PenaltyId3.Direction = ParameterDirection.Output;
                dbParam_PenaltyId3.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId3);

                SqlParameter dbParam_PenaltyId4 = new SqlParameter();
                dbParam_PenaltyId4.ParameterName = "@Penalty4Taker";
                dbParam_PenaltyId4.Value = "";
                dbParam_PenaltyId4.DbType = DbType.Decimal;
                dbParam_PenaltyId4.Direction = ParameterDirection.Output;
                dbParam_PenaltyId4.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId4);

                SqlParameter dbParam_PenaltyId5 = new SqlParameter();
                dbParam_PenaltyId5.ParameterName = "@Penalty5Taker";
                dbParam_PenaltyId5.Value = "";
                dbParam_PenaltyId5.DbType = DbType.Decimal;
                dbParam_PenaltyId5.Direction = ParameterDirection.Output;
                dbParam_PenaltyId5.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId5);

                SqlParameter dbParam_PenaltyId6 = new SqlParameter();
                dbParam_PenaltyId6.ParameterName = "@Penalty6Taker";
                dbParam_PenaltyId6.Value = "";
                dbParam_PenaltyId6.DbType = DbType.Decimal;
                dbParam_PenaltyId6.Direction = ParameterDirection.Output;
                dbParam_PenaltyId6.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId6);

                SqlParameter dbParam_PenaltyId7 = new SqlParameter();
                dbParam_PenaltyId7.ParameterName = "@Penalty7Taker";
                dbParam_PenaltyId7.Value = "";
                dbParam_PenaltyId7.DbType = DbType.Decimal;
                dbParam_PenaltyId7.Direction = ParameterDirection.Output;
                dbParam_PenaltyId7.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId7);

                SqlParameter dbParam_PenaltyId8 = new SqlParameter();
                dbParam_PenaltyId8.ParameterName = "@Penalty8Taker";
                dbParam_PenaltyId8.Value = "";
                dbParam_PenaltyId8.DbType = DbType.Decimal;
                dbParam_PenaltyId8.Direction = ParameterDirection.Output;
                dbParam_PenaltyId8.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId8);

                SqlParameter dbParam_PenaltyId9 = new SqlParameter();
                dbParam_PenaltyId9.ParameterName = "@Penalty9Taker";
                dbParam_PenaltyId9.Value = "";
                dbParam_PenaltyId9.DbType = DbType.Decimal;
                dbParam_PenaltyId9.Direction = ParameterDirection.Output;
                dbParam_PenaltyId9.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId9);

                SqlParameter dbParam_PenaltyId10 = new SqlParameter();
                dbParam_PenaltyId10.ParameterName = "@Penalty10Taker";
                dbParam_PenaltyId10.Value = "";
                dbParam_PenaltyId10.DbType = DbType.Decimal;
                dbParam_PenaltyId10.Direction = ParameterDirection.Output;
                dbParam_PenaltyId10.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId10);

                SqlParameter dbParam_PenaltyId11 = new SqlParameter();
                dbParam_PenaltyId11.ParameterName = "@Penalty11Taker";
                dbParam_PenaltyId11.Value = "";
                dbParam_PenaltyId11.DbType = DbType.Decimal;
                dbParam_PenaltyId11.Direction = ParameterDirection.Output;
                dbParam_PenaltyId11.Size = 12;
                dbCommand.Parameters.Add(dbParam_PenaltyId11);


                SqlParameter dbParam_PositionId1 = new SqlParameter();
                dbParam_PositionId1.ParameterName = "@PositionPlayer1";
                dbParam_PositionId1.Value = "";
                dbParam_PositionId1.DbType = DbType.Decimal;
                dbParam_PositionId1.Direction = ParameterDirection.Output;
                dbParam_PositionId1.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId1);

                SqlParameter dbParam_PositionId2 = new SqlParameter();
                dbParam_PositionId2.ParameterName = "@PositionPlayer2";
                dbParam_PositionId2.Value = "";
                dbParam_PositionId2.DbType = DbType.Decimal;
                dbParam_PositionId2.Direction = ParameterDirection.Output;
                dbParam_PositionId2.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId2);

                SqlParameter dbParam_PositionId3 = new SqlParameter();
                dbParam_PositionId3.ParameterName = "@PositionPlayer3";
                dbParam_PositionId3.Value = "";
                dbParam_PositionId3.DbType = DbType.Decimal;
                dbParam_PositionId3.Direction = ParameterDirection.Output;
                dbParam_PositionId3.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId3);

                SqlParameter dbParam_PositionId4 = new SqlParameter();
                dbParam_PositionId4.ParameterName = "@PositionPlayer4";
                dbParam_PositionId4.Value = "";
                dbParam_PositionId4.DbType = DbType.Decimal;
                dbParam_PositionId4.Direction = ParameterDirection.Output;
                dbParam_PositionId4.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId4);

                SqlParameter dbParam_PositionId5 = new SqlParameter();
                dbParam_PositionId5.ParameterName = "@PositionPlayer5";
                dbParam_PositionId5.Value = "";
                dbParam_PositionId5.DbType = DbType.Decimal;
                dbParam_PositionId5.Direction = ParameterDirection.Output;
                dbParam_PositionId5.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId5);

                SqlParameter dbParam_PositionId6 = new SqlParameter();
                dbParam_PositionId6.ParameterName = "@PositionPlayer6";
                dbParam_PositionId6.Value = "";
                dbParam_PositionId6.DbType = DbType.Decimal;
                dbParam_PositionId6.Direction = ParameterDirection.Output;
                dbParam_PositionId6.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId6);

                SqlParameter dbParam_PositionId7 = new SqlParameter();
                dbParam_PositionId7.ParameterName = "@PositionPlayer7";
                dbParam_PositionId7.Value = "";
                dbParam_PositionId7.DbType = DbType.Decimal;
                dbParam_PositionId7.Direction = ParameterDirection.Output;
                dbParam_PositionId7.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId7);

                SqlParameter dbParam_PositionId8 = new SqlParameter();
                dbParam_PositionId8.ParameterName = "@PositionPlayer8";
                dbParam_PositionId8.Value = "";
                dbParam_PositionId8.DbType = DbType.Decimal;
                dbParam_PositionId8.Direction = ParameterDirection.Output;
                dbParam_PositionId8.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId8);

                SqlParameter dbParam_PositionId9 = new SqlParameter();
                dbParam_PositionId9.ParameterName = "@PositionPlayer9";
                dbParam_PositionId9.Value = "";
                dbParam_PositionId9.DbType = DbType.Decimal;
                dbParam_PositionId9.Direction = ParameterDirection.Output;
                dbParam_PositionId9.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId9);

                SqlParameter dbParam_PositionId10 = new SqlParameter();
                dbParam_PositionId10.ParameterName = "@PositionPlayer10";
                dbParam_PositionId10.Value = "";
                dbParam_PositionId10.DbType = DbType.Decimal;
                dbParam_PositionId10.Direction = ParameterDirection.Output;
                dbParam_PositionId10.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId10);

                SqlParameter dbParam_PositionId11 = new SqlParameter();
                dbParam_PositionId11.ParameterName = "@PositionPlayer11";
                dbParam_PositionId11.Value = "";
                dbParam_PositionId11.DbType = DbType.Decimal;
                dbParam_PositionId11.Direction = ParameterDirection.Output;
                dbParam_PositionId11.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId11);

                SqlParameter dbParam_PositionId12 = new SqlParameter();
                dbParam_PositionId12.ParameterName = "@PositionPlayer12";
                dbParam_PositionId12.Value = "";
                dbParam_PositionId12.DbType = DbType.Decimal;
                dbParam_PositionId12.Direction = ParameterDirection.Output;
                dbParam_PositionId12.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId12);

                SqlParameter dbParam_PositionId13 = new SqlParameter();
                dbParam_PositionId13.ParameterName = "@PositionPlayer13";
                dbParam_PositionId13.Value = "";
                dbParam_PositionId13.DbType = DbType.Decimal;
                dbParam_PositionId13.Direction = ParameterDirection.Output;
                dbParam_PositionId13.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId13);

                SqlParameter dbParam_PositionId14 = new SqlParameter();
                dbParam_PositionId14.ParameterName = "@PositionPlayer14";
                dbParam_PositionId14.Value = "";
                dbParam_PositionId14.DbType = DbType.Decimal;
                dbParam_PositionId14.Direction = ParameterDirection.Output;
                dbParam_PositionId14.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId14);

                SqlParameter dbParam_PositionId15 = new SqlParameter();
                dbParam_PositionId15.ParameterName = "@PositionPlayer15";
                dbParam_PositionId15.Value = "";
                dbParam_PositionId15.DbType = DbType.Decimal;
                dbParam_PositionId15.Direction = ParameterDirection.Output;
                dbParam_PositionId15.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId15);

                SqlParameter dbParam_PositionId16 = new SqlParameter();
                dbParam_PositionId16.ParameterName = "@PositionPlayer16";
                dbParam_PositionId16.Value = "";
                dbParam_PositionId16.DbType = DbType.Decimal;
                dbParam_PositionId16.Direction = ParameterDirection.Output;
                dbParam_PositionId16.Size = 2;
                dbCommand.Parameters.Add(dbParam_PositionId16);

                SqlParameter dbParam_InstructionId1 = new SqlParameter();
                dbParam_InstructionId1.ParameterName = "@InstructionPlayer1";
                dbParam_InstructionId1.Value = "";
                dbParam_InstructionId1.DbType = DbType.Decimal;
                dbParam_InstructionId1.Direction = ParameterDirection.Output;
                dbParam_InstructionId1.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId1);

                SqlParameter dbParam_InstructionId2 = new SqlParameter();
                dbParam_InstructionId2.ParameterName = "@InstructionPlayer2";
                dbParam_InstructionId2.Value = "";
                dbParam_InstructionId2.DbType = DbType.Decimal;
                dbParam_InstructionId2.Direction = ParameterDirection.Output;
                dbParam_InstructionId2.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId2);

                SqlParameter dbParam_InstructionId3 = new SqlParameter();
                dbParam_InstructionId3.ParameterName = "@InstructionPlayer3";
                dbParam_InstructionId3.Value = "";
                dbParam_InstructionId3.DbType = DbType.Decimal;
                dbParam_InstructionId3.Direction = ParameterDirection.Output;
                dbParam_InstructionId3.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId3);

                SqlParameter dbParam_InstructionId4 = new SqlParameter();
                dbParam_InstructionId4.ParameterName = "@InstructionPlayer4";
                dbParam_InstructionId4.Value = "";
                dbParam_InstructionId4.DbType = DbType.Decimal;
                dbParam_InstructionId4.Direction = ParameterDirection.Output;
                dbParam_InstructionId4.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId4);

                SqlParameter dbParam_InstructionId5 = new SqlParameter();
                dbParam_InstructionId5.ParameterName = "@InstructionPlayer5";
                dbParam_InstructionId5.Value = "";
                dbParam_InstructionId5.DbType = DbType.Decimal;
                dbParam_InstructionId5.Direction = ParameterDirection.Output;
                dbParam_InstructionId5.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId5);

                SqlParameter dbParam_InstructionId6 = new SqlParameter();
                dbParam_InstructionId6.ParameterName = "@InstructionPlayer6";
                dbParam_InstructionId6.Value = "";
                dbParam_InstructionId6.DbType = DbType.Decimal;
                dbParam_InstructionId6.Direction = ParameterDirection.Output;
                dbParam_InstructionId6.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId6);

                SqlParameter dbParam_InstructionId7 = new SqlParameter();
                dbParam_InstructionId7.ParameterName = "@InstructionPlayer7";
                dbParam_InstructionId7.Value = "";
                dbParam_InstructionId7.DbType = DbType.Decimal;
                dbParam_InstructionId7.Direction = ParameterDirection.Output;
                dbParam_InstructionId7.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId7);

                SqlParameter dbParam_InstructionId8 = new SqlParameter();
                dbParam_InstructionId8.ParameterName = "@InstructionPlayer8";
                dbParam_InstructionId8.Value = "";
                dbParam_InstructionId8.DbType = DbType.Decimal;
                dbParam_InstructionId8.Direction = ParameterDirection.Output;
                dbParam_InstructionId8.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId8);

                SqlParameter dbParam_InstructionId9 = new SqlParameter();
                dbParam_InstructionId9.ParameterName = "@InstructionPlayer9";
                dbParam_InstructionId9.Value = "";
                dbParam_InstructionId9.DbType = DbType.Decimal;
                dbParam_InstructionId9.Direction = ParameterDirection.Output;
                dbParam_InstructionId9.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId9);

                SqlParameter dbParam_InstructionId10 = new SqlParameter();
                dbParam_InstructionId10.ParameterName = "@InstructionPlayer10";
                dbParam_InstructionId10.Value = "";
                dbParam_InstructionId10.DbType = DbType.Decimal;
                dbParam_InstructionId10.Direction = ParameterDirection.Output;
                dbParam_InstructionId10.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId10);

                SqlParameter dbParam_InstructionId11 = new SqlParameter();
                dbParam_InstructionId11.ParameterName = "@InstructionPlayer11";
                dbParam_InstructionId11.Value = "";
                dbParam_InstructionId11.DbType = DbType.Decimal;
                dbParam_InstructionId11.Direction = ParameterDirection.Output;
                dbParam_InstructionId11.Size = 12;
                dbCommand.Parameters.Add(dbParam_InstructionId11);

                SqlParameter dbParam_AggressivenessId1 = new SqlParameter();
                dbParam_AggressivenessId1.ParameterName = "@AggressivenessPlayer1";
                dbParam_AggressivenessId1.Value = "";
                dbParam_AggressivenessId1.DbType = DbType.Decimal;
                dbParam_AggressivenessId1.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId1.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId1);

                SqlParameter dbParam_AggressivenessId2 = new SqlParameter();
                dbParam_AggressivenessId2.ParameterName = "@AggressivenessPlayer2";
                dbParam_AggressivenessId2.Value = "";
                dbParam_AggressivenessId2.DbType = DbType.Decimal;
                dbParam_AggressivenessId2.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId2.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId2);

                SqlParameter dbParam_AggressivenessId3 = new SqlParameter();
                dbParam_AggressivenessId3.ParameterName = "@AggressivenessPlayer3";
                dbParam_AggressivenessId3.Value = "";
                dbParam_AggressivenessId3.DbType = DbType.Decimal;
                dbParam_AggressivenessId3.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId3.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId3);

                SqlParameter dbParam_AggressivenessId4 = new SqlParameter();
                dbParam_AggressivenessId4.ParameterName = "@AggressivenessPlayer4";
                dbParam_AggressivenessId4.Value = "";
                dbParam_AggressivenessId4.DbType = DbType.Decimal;
                dbParam_AggressivenessId4.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId4.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId4);

                SqlParameter dbParam_AggressivenessId5 = new SqlParameter();
                dbParam_AggressivenessId5.ParameterName = "@AggressivenessPlayer5";
                dbParam_AggressivenessId5.Value = "";
                dbParam_AggressivenessId5.DbType = DbType.Decimal;
                dbParam_AggressivenessId5.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId5.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId5);

                SqlParameter dbParam_AggressivenessId6 = new SqlParameter();
                dbParam_AggressivenessId6.ParameterName = "@AggressivenessPlayer6";
                dbParam_AggressivenessId6.Value = "";
                dbParam_AggressivenessId6.DbType = DbType.Decimal;
                dbParam_AggressivenessId6.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId6.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId6);

                SqlParameter dbParam_AggressivenessId7 = new SqlParameter();
                dbParam_AggressivenessId7.ParameterName = "@AggressivenessPlayer7";
                dbParam_AggressivenessId7.Value = "";
                dbParam_AggressivenessId7.DbType = DbType.Decimal;
                dbParam_AggressivenessId7.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId7.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId7);

                SqlParameter dbParam_AggressivenessId8 = new SqlParameter();
                dbParam_AggressivenessId8.ParameterName = "@AggressivenessPlayer8";
                dbParam_AggressivenessId8.Value = "";
                dbParam_AggressivenessId8.DbType = DbType.Decimal;
                dbParam_AggressivenessId8.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId8.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId8);

                SqlParameter dbParam_AggressivenessId9 = new SqlParameter();
                dbParam_AggressivenessId9.ParameterName = "@AggressivenessPlayer9";
                dbParam_AggressivenessId9.Value = "";
                dbParam_AggressivenessId9.DbType = DbType.Decimal;
                dbParam_AggressivenessId9.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId9.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId9);

                SqlParameter dbParam_AggressivenessId10 = new SqlParameter();
                dbParam_AggressivenessId10.ParameterName = "@AggressivenessPlayer10";
                dbParam_AggressivenessId10.Value = "";
                dbParam_AggressivenessId10.DbType = DbType.Decimal;
                dbParam_AggressivenessId10.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId10.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId10);

                SqlParameter dbParam_AggressivenessId11 = new SqlParameter();
                dbParam_AggressivenessId11.ParameterName = "@AggressivenessPlayer11";
                dbParam_AggressivenessId11.Value = "";
                dbParam_AggressivenessId11.DbType = DbType.Decimal;
                dbParam_AggressivenessId11.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId11.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId11);

                SqlParameter dbParam_AggressivenessId12 = new SqlParameter();
                dbParam_AggressivenessId12.ParameterName = "@AggressivenessPlayer12";
                dbParam_AggressivenessId12.Value = "";
                dbParam_AggressivenessId12.DbType = DbType.Decimal;
                dbParam_AggressivenessId12.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId12.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId12);

                SqlParameter dbParam_AggressivenessId13 = new SqlParameter();
                dbParam_AggressivenessId13.ParameterName = "@AggressivenessPlayer13";
                dbParam_AggressivenessId13.Value = "";
                dbParam_AggressivenessId13.DbType = DbType.Decimal;
                dbParam_AggressivenessId13.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId13.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId13);

                SqlParameter dbParam_AggressivenessId14 = new SqlParameter();
                dbParam_AggressivenessId14.ParameterName = "@AggressivenessPlayer14";
                dbParam_AggressivenessId14.Value = "";
                dbParam_AggressivenessId14.DbType = DbType.Decimal;
                dbParam_AggressivenessId14.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId14.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId14);

                SqlParameter dbParam_AggressivenessId15 = new SqlParameter();
                dbParam_AggressivenessId15.ParameterName = "@AggressivenessPlayer15";
                dbParam_AggressivenessId15.Value = "";
                dbParam_AggressivenessId15.DbType = DbType.Decimal;
                dbParam_AggressivenessId15.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId15.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId15);

                SqlParameter dbParam_AggressivenessId16 = new SqlParameter();
                dbParam_AggressivenessId16.ParameterName = "@AggressivenessPlayer16";
                dbParam_AggressivenessId16.Value = "";
                dbParam_AggressivenessId16.DbType = DbType.Decimal;
                dbParam_AggressivenessId16.Direction = ParameterDirection.Output;
                dbParam_AggressivenessId16.Size = 2;
                dbCommand.Parameters.Add(dbParam_AggressivenessId16);

                SqlParameter dbParam_AttitudeId1 = new SqlParameter();
                dbParam_AttitudeId1.ParameterName = "@Attitudeplayer1";
                dbParam_AttitudeId1.Value = "";
                dbParam_AttitudeId1.DbType = DbType.Decimal;
                dbParam_AttitudeId1.Direction = ParameterDirection.Output;
                dbParam_AttitudeId1.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId1);

                SqlParameter dbParam_AttitudeId2 = new SqlParameter();
                dbParam_AttitudeId2.ParameterName = "@Attitudeplayer2";
                dbParam_AttitudeId2.Value = "";
                dbParam_AttitudeId2.DbType = DbType.Decimal;
                dbParam_AttitudeId2.Direction = ParameterDirection.Output;
                dbParam_AttitudeId2.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId2);

                SqlParameter dbParam_AttitudeId3 = new SqlParameter();
                dbParam_AttitudeId3.ParameterName = "@Attitudeplayer3";
                dbParam_AttitudeId3.Value = "";
                dbParam_AttitudeId3.DbType = DbType.Decimal;
                dbParam_AttitudeId3.Direction = ParameterDirection.Output;
                dbParam_AttitudeId3.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId3);

                SqlParameter dbParam_AttitudeId4 = new SqlParameter();
                dbParam_AttitudeId4.ParameterName = "@Attitudeplayer4";
                dbParam_AttitudeId4.Value = "";
                dbParam_AttitudeId4.DbType = DbType.Decimal;
                dbParam_AttitudeId4.Direction = ParameterDirection.Output;
                dbParam_AttitudeId4.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId4);

                SqlParameter dbParam_AttitudeId5 = new SqlParameter();
                dbParam_AttitudeId5.ParameterName = "@Attitudeplayer5";
                dbParam_AttitudeId5.Value = "";
                dbParam_AttitudeId5.DbType = DbType.Decimal;
                dbParam_AttitudeId5.Direction = ParameterDirection.Output;
                dbParam_AttitudeId5.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId5);

                SqlParameter dbParam_AttitudeId6 = new SqlParameter();
                dbParam_AttitudeId6.ParameterName = "@Attitudeplayer6";
                dbParam_AttitudeId6.Value = "";
                dbParam_AttitudeId6.DbType = DbType.Decimal;
                dbParam_AttitudeId6.Direction = ParameterDirection.Output;
                dbParam_AttitudeId6.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId6);

                SqlParameter dbParam_AttitudeId7 = new SqlParameter();
                dbParam_AttitudeId7.ParameterName = "@Attitudeplayer7";
                dbParam_AttitudeId7.Value = "";
                dbParam_AttitudeId7.DbType = DbType.Decimal;
                dbParam_AttitudeId7.Direction = ParameterDirection.Output;
                dbParam_AttitudeId7.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId7);

                SqlParameter dbParam_AttitudeId8 = new SqlParameter();
                dbParam_AttitudeId8.ParameterName = "@Attitudeplayer8";
                dbParam_AttitudeId8.Value = "";
                dbParam_AttitudeId8.DbType = DbType.Decimal;
                dbParam_AttitudeId8.Direction = ParameterDirection.Output;
                dbParam_AttitudeId8.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId8);

                SqlParameter dbParam_AttitudeId9 = new SqlParameter();
                dbParam_AttitudeId9.ParameterName = "@Attitudeplayer9";
                dbParam_AttitudeId9.Value = "";
                dbParam_AttitudeId9.DbType = DbType.Decimal;
                dbParam_AttitudeId9.Direction = ParameterDirection.Output;
                dbParam_AttitudeId9.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId9);

                SqlParameter dbParam_AttitudeId10 = new SqlParameter();
                dbParam_AttitudeId10.ParameterName = "@Attitudeplayer10";
                dbParam_AttitudeId10.Value = "";
                dbParam_AttitudeId10.DbType = DbType.Decimal;
                dbParam_AttitudeId10.Direction = ParameterDirection.Output;
                dbParam_AttitudeId10.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId10);

                SqlParameter dbParam_AttitudeId11 = new SqlParameter();
                dbParam_AttitudeId11.ParameterName = "@Attitudeplayer11";
                dbParam_AttitudeId11.Value = "";
                dbParam_AttitudeId11.DbType = DbType.Decimal;
                dbParam_AttitudeId11.Direction = ParameterDirection.Output;
                dbParam_AttitudeId11.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId11);

                SqlParameter dbParam_AttitudeId12 = new SqlParameter();
                dbParam_AttitudeId12.ParameterName = "@Attitudeplayer12";
                dbParam_AttitudeId12.Value = "";
                dbParam_AttitudeId12.DbType = DbType.Decimal;
                dbParam_AttitudeId12.Direction = ParameterDirection.Output;
                dbParam_AttitudeId12.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId12);

                SqlParameter dbParam_AttitudeId13 = new SqlParameter();
                dbParam_AttitudeId13.ParameterName = "@Attitudeplayer13";
                dbParam_AttitudeId13.Value = "";
                dbParam_AttitudeId13.DbType = DbType.Decimal;
                dbParam_AttitudeId13.Direction = ParameterDirection.Output;
                dbParam_AttitudeId13.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId13);

                SqlParameter dbParam_AttitudeId14 = new SqlParameter();
                dbParam_AttitudeId14.ParameterName = "@Attitudeplayer14";
                dbParam_AttitudeId14.Value = "";
                dbParam_AttitudeId14.DbType = DbType.Decimal;
                dbParam_AttitudeId14.Direction = ParameterDirection.Output;
                dbParam_AttitudeId14.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId14);

                SqlParameter dbParam_AttitudeId15 = new SqlParameter();
                dbParam_AttitudeId15.ParameterName = "@Attitudeplayer15";
                dbParam_AttitudeId15.Value = "";
                dbParam_AttitudeId15.DbType = DbType.Decimal;
                dbParam_AttitudeId15.Direction = ParameterDirection.Output;
                dbParam_AttitudeId15.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId15);

                SqlParameter dbParam_AttitudeId16 = new SqlParameter();
                dbParam_AttitudeId16.ParameterName = "@Attitudeplayer16";
                dbParam_AttitudeId16.Value = "";
                dbParam_AttitudeId16.DbType = DbType.Decimal;
                dbParam_AttitudeId16.Direction = ParameterDirection.Output;
                dbParam_AttitudeId16.Size = 2;
                dbCommand.Parameters.Add(dbParam_AttitudeId16);

                SqlParameter dbParam_PreferredActionId1 = new SqlParameter();
                dbParam_PreferredActionId1.ParameterName = "@PreferredActionplayer1";
                dbParam_PreferredActionId1.Value = "";
                dbParam_PreferredActionId1.DbType = DbType.Decimal;
                dbParam_PreferredActionId1.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId1.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId1);

                SqlParameter dbParam_PreferredActionId2 = new SqlParameter();
                dbParam_PreferredActionId2.ParameterName = "@PreferredActionplayer2";
                dbParam_PreferredActionId2.Value = "";
                dbParam_PreferredActionId2.DbType = DbType.Decimal;
                dbParam_PreferredActionId2.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId2.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId2);

                SqlParameter dbParam_PreferredActionId3 = new SqlParameter();
                dbParam_PreferredActionId3.ParameterName = "@PreferredActionplayer3";
                dbParam_PreferredActionId3.Value = "";
                dbParam_PreferredActionId3.DbType = DbType.Decimal;
                dbParam_PreferredActionId3.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId3.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId3);

                SqlParameter dbParam_PreferredActionId4 = new SqlParameter();
                dbParam_PreferredActionId4.ParameterName = "@PreferredActionplayer4";
                dbParam_PreferredActionId4.Value = "";
                dbParam_PreferredActionId4.DbType = DbType.Decimal;
                dbParam_PreferredActionId4.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId4.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId4);

                SqlParameter dbParam_PreferredActionId5 = new SqlParameter();
                dbParam_PreferredActionId5.ParameterName = "@PreferredActionplayer5";
                dbParam_PreferredActionId5.Value = "";
                dbParam_PreferredActionId5.DbType = DbType.Decimal;
                dbParam_PreferredActionId5.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId5.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId5);

                SqlParameter dbParam_PreferredActionId6 = new SqlParameter();
                dbParam_PreferredActionId6.ParameterName = "@PreferredActionplayer6";
                dbParam_PreferredActionId6.Value = "";
                dbParam_PreferredActionId6.DbType = DbType.Decimal;
                dbParam_PreferredActionId6.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId6.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId6);

                SqlParameter dbParam_PreferredActionId7 = new SqlParameter();
                dbParam_PreferredActionId7.ParameterName = "@PreferredActionplayer7";
                dbParam_PreferredActionId7.Value = "";
                dbParam_PreferredActionId7.DbType = DbType.Decimal;
                dbParam_PreferredActionId7.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId7.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId7);

                SqlParameter dbParam_PreferredActionId8 = new SqlParameter();
                dbParam_PreferredActionId8.ParameterName = "@PreferredActionplayer8";
                dbParam_PreferredActionId8.Value = "";
                dbParam_PreferredActionId8.DbType = DbType.Decimal;
                dbParam_PreferredActionId8.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId8.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId8);

                SqlParameter dbParam_PreferredActionId9 = new SqlParameter();
                dbParam_PreferredActionId9.ParameterName = "@PreferredActionplayer9";
                dbParam_PreferredActionId9.Value = "";
                dbParam_PreferredActionId9.DbType = DbType.Decimal;
                dbParam_PreferredActionId9.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId9.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId9);

                SqlParameter dbParam_PreferredActionId10 = new SqlParameter();
                dbParam_PreferredActionId10.ParameterName = "@PreferredActionplayer10";
                dbParam_PreferredActionId10.Value = "";
                dbParam_PreferredActionId10.DbType = DbType.Decimal;
                dbParam_PreferredActionId10.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId10.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId10);

                SqlParameter dbParam_PreferredActionId11 = new SqlParameter();
                dbParam_PreferredActionId11.ParameterName = "@PreferredActionplayer11";
                dbParam_PreferredActionId11.Value = "";
                dbParam_PreferredActionId11.DbType = DbType.Decimal;
                dbParam_PreferredActionId11.Direction = ParameterDirection.Output;
                dbParam_PreferredActionId11.Size = 2;
                dbCommand.Parameters.Add(dbParam_PreferredActionId11);

                SqlParameter dbParam_TeamAggressiveness = new SqlParameter();
                dbParam_TeamAggressiveness.ParameterName = "@TeamAggressiveness";
                dbParam_TeamAggressiveness.Value = "";
                dbParam_TeamAggressiveness.DbType = DbType.Decimal;
                dbParam_TeamAggressiveness.Direction = ParameterDirection.Output;
                dbParam_TeamAggressiveness.Size = 2;
                dbCommand.Parameters.Add(dbParam_TeamAggressiveness);


                SqlParameter dbParam_TeamAttitude = new SqlParameter();
                dbParam_TeamAttitude.ParameterName = "@TeamAttitude";
                dbParam_TeamAttitude.Value = "";
                dbParam_TeamAttitude.DbType = DbType.Decimal;
                dbParam_TeamAttitude.Direction = ParameterDirection.Output;
                dbParam_TeamAttitude.Size = 2;
                dbCommand.Parameters.Add(dbParam_TeamAttitude);


                SqlParameter dbParam_Captain = new SqlParameter();
                dbParam_Captain.ParameterName = "@Captain";
                dbParam_Captain.Value = "";
                dbParam_Captain.DbType = DbType.Decimal;
                dbParam_Captain.Direction = ParameterDirection.Output;
                dbParam_Captain.Size = 2;
                dbCommand.Parameters.Add(dbParam_Captain);


                SqlParameter dbParam_SetPiecesTaker = new SqlParameter();
                dbParam_SetPiecesTaker.ParameterName = "@SetPiecesTaker";
                dbParam_SetPiecesTaker.Value = "";
                dbParam_SetPiecesTaker.DbType = DbType.Decimal;
                dbParam_SetPiecesTaker.Direction = ParameterDirection.Output;
                dbParam_SetPiecesTaker.Size = 2;
                dbCommand.Parameters.Add(dbParam_SetPiecesTaker);

            #endregion define sql parameters

                try
                {
                    dbConnection.Open();
                    dbCommand.ExecuteNonQuery();
                    PutPlayerOnPitch(dbParam_PlayerId1.Value.ToString(), dbParam_PositionId1.Value.ToString(),
                                     dbParam_PreferredActionId1.Value.ToString(), dbParam_InstructionId1.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId2.Value.ToString(), dbParam_PositionId2.Value.ToString(),
                                     dbParam_PreferredActionId2.Value.ToString(), dbParam_InstructionId2.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId3.Value.ToString(), dbParam_PositionId3.Value.ToString(),
                                     dbParam_PreferredActionId3.Value.ToString(), dbParam_InstructionId3.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId4.Value.ToString(), dbParam_PositionId4.Value.ToString(),
                                     dbParam_PreferredActionId4.Value.ToString(), dbParam_InstructionId4.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId5.Value.ToString(), dbParam_PositionId5.Value.ToString(),
                                     dbParam_PreferredActionId5.Value.ToString(), dbParam_InstructionId5.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId6.Value.ToString(), dbParam_PositionId6.Value.ToString(),
                                     dbParam_PreferredActionId6.Value.ToString(), dbParam_InstructionId6.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId7.Value.ToString(), dbParam_PositionId7.Value.ToString(),
                                     dbParam_PreferredActionId7.Value.ToString(), dbParam_InstructionId7.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId8.Value.ToString(), dbParam_PositionId8.Value.ToString(),
                                     dbParam_PreferredActionId8.Value.ToString(), dbParam_InstructionId8.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId9.Value.ToString(), dbParam_PositionId9.Value.ToString(),
                                     dbParam_PreferredActionId9.Value.ToString(), dbParam_InstructionId9.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId10.Value.ToString(), dbParam_PositionId10.Value.ToString(),
                                     dbParam_PreferredActionId10.Value.ToString(), dbParam_InstructionId10.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId11.Value.ToString(), dbParam_PositionId11.Value.ToString(),
                                     dbParam_PreferredActionId11.Value.ToString(), dbParam_InstructionId11.Value.ToString());
                    PutPlayerOnPitch(dbParam_PlayerId12.Value.ToString(), dbParam_PositionId12.Value.ToString(), "", "");
                    PutPlayerOnPitch(dbParam_PlayerId13.Value.ToString(), dbParam_PositionId13.Value.ToString(), "", "");
                    PutPlayerOnPitch(dbParam_PlayerId14.Value.ToString(), dbParam_PositionId14.Value.ToString(), "", "");
                    PutPlayerOnPitch(dbParam_PlayerId15.Value.ToString(), dbParam_PositionId15.Value.ToString(), "", "");
                    PutPlayerOnPitch(dbParam_PlayerId16.Value.ToString(), dbParam_PositionId16.Value.ToString(), "", "");

                    // captain
                    CaptainHiddenField.Value = dbParam_Captain.Value.ToString();

                    // set pieces taker
                    SetPiecesTakerHiddenField.Value = dbParam_SetPiecesTaker.Value.ToString();

                    // team attitude
                    TeamAttitudeDropDownList.SelectedValue = dbParam_TeamAttitude.Value.ToString();

                    // team aggressiveness
                    TeamAggressivenessDropDownList.SelectedValue = dbParam_TeamAggressiveness.Value.ToString();

                    // penalties
                    PenaltyTaker1HiddenField.Value = dbParam_PenaltyId1.Value.ToString();
                    PenaltyTaker2HiddenField.Value = dbParam_PenaltyId2.Value.ToString();
                    PenaltyTaker3HiddenField.Value = dbParam_PenaltyId3.Value.ToString();
                    PenaltyTaker4HiddenField.Value = dbParam_PenaltyId4.Value.ToString();
                    PenaltyTaker5HiddenField.Value = dbParam_PenaltyId5.Value.ToString();
                    PenaltyTaker6HiddenField.Value = dbParam_PenaltyId6.Value.ToString();
                    PenaltyTaker7HiddenField.Value = dbParam_PenaltyId7.Value.ToString();
                    PenaltyTaker8HiddenField.Value = dbParam_PenaltyId8.Value.ToString();
                    PenaltyTaker9HiddenField.Value = dbParam_PenaltyId9.Value.ToString();
                    PenaltyTaker10HiddenField.Value = dbParam_PenaltyId10.Value.ToString();
                    PenaltyTaker11HiddenField.Value = dbParam_PenaltyId11.Value.ToString();

                    PenaltyDropDownList1.SelectedValue = dbParam_PenaltyId1.Value.ToString();
                    PenaltyDropDownList2.SelectedValue = dbParam_PenaltyId2.Value.ToString();
                    PenaltyDropDownList3.SelectedValue = dbParam_PenaltyId3.Value.ToString();
                    PenaltyDropDownList4.SelectedValue = dbParam_PenaltyId4.Value.ToString();
                    PenaltyDropDownList5.SelectedValue = dbParam_PenaltyId5.Value.ToString();
                    PenaltyDropDownList6.SelectedValue = dbParam_PenaltyId6.Value.ToString();
                    PenaltyDropDownList7.SelectedValue = dbParam_PenaltyId7.Value.ToString();
                    PenaltyDropDownList8.SelectedValue = dbParam_PenaltyId8.Value.ToString();
                    PenaltyDropDownList9.SelectedValue = dbParam_PenaltyId9.Value.ToString();
                    PenaltyDropDownList10.SelectedValue = dbParam_PenaltyId10.Value.ToString();
                    PenaltyDropDownList11.SelectedValue = dbParam_PenaltyId11.Value.ToString();
                }
                catch { }
                finally
                {
                    dbConnection.Close();
                }

            }
        }

        protected void LoadSubstitutions(string MatchId)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("Nivdal_GetSubstitutionsForMatch", conn);
            SqlDataReader reader;
            string PlayerIn, PlayerOut;
            int CurrentSub = 1;
            int dbg = 0;

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@TeamId", TeamIdHiddenField.Value));
            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MatchId", MatchId));
            cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Language", LanguageHiddenField.Value));


            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                    while (reader.Read())
                    {
                        #region swicth_currentSub
                        switch (CurrentSub)
                        {
                            case 1:
                                Sub1TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub1TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub1PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub1PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub1ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub1ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub1YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub1RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub1PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub1PlayerOutLabel.Text = reader.GetString(9);
                                Sub1PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub1PlayerInLabel.Text = reader.GetString(11);
                                Sub1NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub1NewPositionLabel.Text = reader.GetString(13);
                                Sub1NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub1NewInstructionLabel.Text = reader.GetString(15);
                                Sub1NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub1NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub1NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub1NewAttitudeLabel.Text = reader.GetString(19);
                                Sub1NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub1NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub1TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub1TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub1TypeHiddenField.Value = "3";
                                }

                                break;
                            case 2:
                                Sub2TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub2TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub2PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub2PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub2ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub2ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub2YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub2RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub2PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub2PlayerOutLabel.Text = reader.GetString(9);
                                Sub2PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub2PlayerInLabel.Text = reader.GetString(11);
                                Sub2NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub2NewPositionLabel.Text = reader.GetString(13);
                                Sub2NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub2NewInstructionLabel.Text = reader.GetString(15);
                                Sub2NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub2NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub2NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub2NewAttitudeLabel.Text = reader.GetString(19);
                                Sub2NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub2NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub2TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub2TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub2TypeHiddenField.Value = "3";
                                }
                                break;
                            case 3:
                                Sub3TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub3TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub3PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub3PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub3ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub3ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub3YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub3RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub3PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub3PlayerOutLabel.Text = reader.GetString(9);
                                Sub3PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub3PlayerInLabel.Text = reader.GetString(11);
                                Sub3NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub3NewPositionLabel.Text = reader.GetString(13);
                                Sub3NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub3NewInstructionLabel.Text = reader.GetString(15);
                                Sub3NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub3NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub3NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub3NewAttitudeLabel.Text = reader.GetString(19);
                                Sub3NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub3NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub3TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub3TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub3TypeHiddenField.Value = "3";
                                }
                                break;

                            case 4:
                                Sub4TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub4TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub4PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub4PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub4ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub4ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub4YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub4RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub4PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub4PlayerOutLabel.Text = reader.GetString(9);
                                Sub4PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub4PlayerInLabel.Text = reader.GetString(11);
                                Sub4NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub4NewPositionLabel.Text = reader.GetString(13);
                                Sub4NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub4NewInstructionLabel.Text = reader.GetString(15);
                                Sub4NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub4NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub4NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub4NewAttitudeLabel.Text = reader.GetString(19);
                                Sub4NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub4NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub4TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub4TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub4TypeHiddenField.Value = "3";
                                }
                                break;
                            case 5:
                                Sub5TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub5TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub5PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub5PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub5ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub5ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub5YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub5RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub5PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub5PlayerOutLabel.Text = reader.GetString(9);
                                Sub5PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub5PlayerInLabel.Text = reader.GetString(11);
                                Sub5NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub5NewPositionLabel.Text = reader.GetString(13);
                                Sub5NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub5NewInstructionLabel.Text = reader.GetString(15);
                                Sub5NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub5NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub5NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub5NewAttitudeLabel.Text = reader.GetString(19);
                                Sub5NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub5NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub5TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub5TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub5TypeHiddenField.Value = "3";
                                }
                                break;
                            case 6:
                                Sub6TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub6TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub6PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub6PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub6ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub6ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub6YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub6RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub6PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub6PlayerOutLabel.Text = reader.GetString(9);
                                Sub6PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub6PlayerInLabel.Text = reader.GetString(11);
                                Sub6NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub6NewPositionLabel.Text = reader.GetString(13);
                                Sub6NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub6NewInstructionLabel.Text = reader.GetString(15);
                                Sub6NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub6NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub6NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub6NewAttitudeLabel.Text = reader.GetString(19);
                                Sub6NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub6NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub6TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub6TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub6TypeHiddenField.Value = "3";
                                }
                                break;
                            case 7:
                                Sub7TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub7TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub7PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub7PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub7ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub7ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub7YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub7RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub7PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub7PlayerOutLabel.Text = reader.GetString(9);
                                Sub7PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub7PlayerInLabel.Text = reader.GetString(11);
                                Sub7NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub7NewPositionLabel.Text = reader.GetString(13);
                                Sub7NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub7NewInstructionLabel.Text = reader.GetString(15);
                                Sub7NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub7NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub7NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub7NewAttitudeLabel.Text = reader.GetString(19);
                                Sub7NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub7NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub7TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub7TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub7TypeHiddenField.Value = "3";
                                }
                                break;
                            case 8:
                                Sub8TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub8TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub8PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub8PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub8ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub8ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub8YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub8RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub8PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub8PlayerOutLabel.Text = reader.GetString(9);
                                Sub8PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub8PlayerInLabel.Text = reader.GetString(11);
                                Sub8NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub8NewPositionLabel.Text = reader.GetString(13);
                                Sub8NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub8NewInstructionLabel.Text = reader.GetString(15);
                                Sub8NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub8NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub8NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub8NewAttitudeLabel.Text = reader.GetString(19);
                                Sub8NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub8NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub8TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub8TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub8TypeHiddenField.Value = "3";
                                }
                                break;
                            case 9:
                                Sub9TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub9TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub9PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub9PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub9ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub9ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub9YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub9RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub9PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub9PlayerOutLabel.Text = reader.GetString(9);
                                Sub9PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub9PlayerInLabel.Text = reader.GetString(11);
                                Sub9NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub9NewPositionLabel.Text = reader.GetString(13);
                                Sub9NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub9NewInstructionLabel.Text = reader.GetString(15);
                                Sub9NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub9NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub9NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub9NewAttitudeLabel.Text = reader.GetString(19);
                                Sub9NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub9NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub9TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub9TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub9TypeHiddenField.Value = "3";
                                }
                                break;
                            case 10:
                                Sub10TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub10TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub10PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub10PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub10ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub10ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub10YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub10RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub10PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub10PlayerOutLabel.Text = reader.GetString(9);
                                Sub10PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub10PlayerInLabel.Text = reader.GetString(11);
                                Sub10NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub10NewPositionLabel.Text = reader.GetString(13);
                                Sub10NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub10NewInstructionLabel.Text = reader.GetString(15);
                                Sub10NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub10NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub10NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub10NewAttitudeLabel.Text = reader.GetString(19);
                                Sub10NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub10NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub10TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub10TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub10TypeHiddenField.Value = "3";
                                }
                                break;
                            case 11:
                                Sub11TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub11TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub11PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub11PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub11ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub11ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub11YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub11RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub11PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub11PlayerOutLabel.Text = reader.GetString(9);
                                Sub11PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub11PlayerInLabel.Text = reader.GetString(11);
                                Sub11NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub11NewPositionLabel.Text = reader.GetString(13);
                                Sub11NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub11NewInstructionLabel.Text = reader.GetString(15);
                                Sub11NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub11NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub11NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub11NewAttitudeLabel.Text = reader.GetString(19);
                                Sub11NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub11NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub11TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub11TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub11TypeHiddenField.Value = "3";
                                }
                                break;
                            case 12:
                                Sub12TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub12TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub12PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub12PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub12ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub12ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub12YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub12RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub12PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub12PlayerOutLabel.Text = reader.GetString(9);
                                Sub12PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub12PlayerInLabel.Text = reader.GetString(11);
                                Sub12NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub12NewPositionLabel.Text = reader.GetString(13);
                                Sub12NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub12NewInstructionLabel.Text = reader.GetString(15);
                                Sub12NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub12NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub12NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub12NewAttitudeLabel.Text = reader.GetString(19);
                                Sub12NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub12NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub12TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub12TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub12TypeHiddenField.Value = "3";
                                }
                                break;
                            case 13:
                                Sub13TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub13TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub13PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub13PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub13ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub13ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub13YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub13RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub13PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub13PlayerOutLabel.Text = reader.GetString(9);
                                Sub13PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub13PlayerInLabel.Text = reader.GetString(11);
                                Sub13NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub13NewPositionLabel.Text = reader.GetString(13);
                                Sub13NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub13NewInstructionLabel.Text = reader.GetString(15);
                                Sub13NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub13NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub13NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub13NewAttitudeLabel.Text = reader.GetString(19);
                                Sub13NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub13NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub13TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub13TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub13TypeHiddenField.Value = "3";
                                }
                                break;
                            case 14:
                                Sub14TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub14TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub14PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub14PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub14ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub14ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub14YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub14RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub14PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub14PlayerOutLabel.Text = reader.GetString(9);
                                Sub14PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub14PlayerInLabel.Text = reader.GetString(11);
                                Sub14NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub14NewPositionLabel.Text = reader.GetString(13);
                                Sub14NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub14NewInstructionLabel.Text = reader.GetString(15);
                                Sub14NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub14NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub14NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub14NewAttitudeLabel.Text = reader.GetString(19);
                                Sub14NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub14NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub14TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub14TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub14TypeHiddenField.Value = "3";
                                }
                                break;
                            case 15:
                                Sub15TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub15TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub15PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub15PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub15ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub15ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub15YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub15RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub15PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub15PlayerOutLabel.Text = reader.GetString(9);
                                Sub15PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub15PlayerInLabel.Text = reader.GetString(11);
                                Sub15NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub15NewPositionLabel.Text = reader.GetString(13);
                                Sub15NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub15NewInstructionLabel.Text = reader.GetString(15);
                                Sub15NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub15NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub15NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub15NewAttitudeLabel.Text = reader.GetString(19);
                                Sub15NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub15NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub15TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub15TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub15TypeHiddenField.Value = "3";
                                }
                                break;
                            case 16:
                                Sub16TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub16TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub16PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub16PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub16ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub16ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub16YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub16RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub16PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub16PlayerOutLabel.Text = reader.GetString(9);
                                Sub16PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub16PlayerInLabel.Text = reader.GetString(11);
                                Sub16NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub16NewPositionLabel.Text = reader.GetString(13);
                                Sub16NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub16NewInstructionLabel.Text = reader.GetString(15);
                                Sub16NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub16NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub16NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub16NewAttitudeLabel.Text = reader.GetString(19);
                                Sub16NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub16NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub16TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub16TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub16TypeHiddenField.Value = "3";
                                }
                                break;

                            case 17:
                                Sub17TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub17TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub17PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub17PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub17ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub17ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub17YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub17RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub17PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub17PlayerOutLabel.Text = reader.GetString(9);
                                Sub17PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub17PlayerInLabel.Text = reader.GetString(11);
                                Sub17NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub17NewPositionLabel.Text = reader.GetString(13);
                                Sub17NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub17NewInstructionLabel.Text = reader.GetString(15);
                                Sub17NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub17NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub17NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub17NewAttitudeLabel.Text = reader.GetString(19);
                                Sub17NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub17NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub17TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub17TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub17TypeHiddenField.Value = "3";
                                }
                                break;
                            case 18:
                                Sub18TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub18TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub18PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub18PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub18ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub18ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub18YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub18RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub18PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub18PlayerOutLabel.Text = reader.GetString(9);
                                Sub18PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub18PlayerInLabel.Text = reader.GetString(11);
                                Sub18NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub18NewPositionLabel.Text = reader.GetString(13);
                                Sub18NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub18NewInstructionLabel.Text = reader.GetString(15);
                                Sub18NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub18NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub18NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub18NewAttitudeLabel.Text = reader.GetString(19);
                                Sub18NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub18NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub18TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub18TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub18TypeHiddenField.Value = "3";
                                }
                                break;
                            case 19:
                                Sub19TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub19TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub19PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub19PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub19ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub19ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub19YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub19RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub19PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub19PlayerOutLabel.Text = reader.GetString(9);
                                Sub19PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub19PlayerInLabel.Text = reader.GetString(11);
                                Sub19NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub19NewPositionLabel.Text = reader.GetString(13);
                                Sub19NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub19NewInstructionLabel.Text = reader.GetString(15);
                                Sub19NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub19NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub19NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub19NewAttitudeLabel.Text = reader.GetString(19);
                                Sub19NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub19NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub19TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub19TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub19TypeHiddenField.Value = "3";
                                }
                                break;
                            case 20:
                                Sub20TimeMinHiddenField.Value = reader.GetDecimal(0).ToString();
                                Sub20TimeMaxHiddenField.Value = reader.GetDecimal(1).ToString();
                                Sub20PossessionMinHiddenField.Value = reader.GetDecimal(2).ToString();
                                Sub20PossessionMaxHiddenField.Value = reader.GetDecimal(3).ToString();
                                Sub20ScoreMinHiddenField.Value = reader.GetDecimal(4).ToString();
                                Sub20ScoreMaxHiddenField.Value = reader.GetDecimal(5).ToString();
                                Sub20YellowCardedPlayerHiddenField.Value = reader.GetDecimal(6).ToString();
                                Sub20RedCardedPlayerHiddenField.Value = reader.GetDecimal(7).ToString();
                                Sub20PlayerOutHiddenField.Value = reader.GetDecimal(8).ToString();
                                PlayerOut = reader.GetDecimal(8).ToString();
                                Sub20PlayerOutLabel.Text = reader.GetString(9);
                                Sub20PlayerInHiddenField.Value = reader.GetDecimal(10).ToString();
                                PlayerIn = reader.GetDecimal(10).ToString();
                                Sub20PlayerInLabel.Text = reader.GetString(11);
                                Sub20NewPlayerPositionHiddenField.Value = reader.GetDecimal(12).ToString();
                                Sub20NewPositionLabel.Text = reader.GetString(13);
                                Sub20NewPlayerInstructionHiddenField.Value = reader.GetDecimal(14).ToString();
                                Sub20NewInstructionLabel.Text = reader.GetString(15);
                                Sub20NewPlayerPreferredActionHiddenField.Value = reader.GetDecimal(16).ToString();
                                Sub20NewPreferredActionLabel.Text = reader.GetString(17);
                                Sub20NewTeamAttitudeHiddenField.Value = reader.GetDecimal(18).ToString();
                                Sub20NewAttitudeLabel.Text = reader.GetString(19);
                                Sub20NewTeamAggressivenessHiddenField.Value = reader.GetDecimal(20).ToString();
                                Sub20NewAggressivenessLabel.Text = reader.GetString(21);
                                // setting substitution type
                                if ((PlayerOut != "0") && (PlayerIn != "0"))
                                {
                                    // substitution
                                    Sub20TypeHiddenField.Value = "1";
                                }
                                else if (PlayerOut != "0")
                                {
                                    // player change
                                    Sub20TypeHiddenField.Value = "2";
                                }
                                else
                                {
                                    // team change
                                    Sub20TypeHiddenField.Value = "3";
                                }
                                break;
                            default:
                                break;

                        }
                        #endregion swicth_currentSub

                        CurrentSub++;
                    }
            }
            catch (Exception err) { DebugLabel.Text = err.Message + " dbg is " + dbg.ToString(); }
            finally { conn.Close(); }

        }

        #region SubmitOrders

        private struct PlayerInMatch
        {
            public string Id;
            public string Position;
            public string PreferredAction;
            public string Instruction;
        }

        private struct SubPlayer
        {
            public string Id;
            public string Position;
        }

        private LinkedList<PlayerInMatch> GetSelectedOutfieldPlayers()
        {
            LinkedList<PlayerInMatch> Players = new LinkedList<PlayerInMatch>();
            PlayerInMatch Player;

            //1	Goalkeeper
            if (KeeperPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = KeeperPlayerIdHiddenField.Value;
                Player.Position = "1";
                Player.Instruction = "2";
                Player.PreferredAction = "2";
                Players.AddFirst(Player);
            }

            if (LeftDefencePlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = LeftDefencePlayerIdHiddenField.Value;
                Player.Position = "2";
                Player.Instruction = LeftDefenceInstructionHiddenField.Value;
                Player.PreferredAction = LeftDefencePreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (LeftCenterDefencePlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = LeftCenterDefencePlayerIdHiddenField.Value;
                Player.Position = "3";
                Player.Instruction = LeftCenterDefenceInstructionHiddenField.Value;
                Player.PreferredAction = LeftCenterDefencePreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (CenterDefencePlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = CenterDefencePlayerIdHiddenField.Value;
                Player.Position = "4";
                Player.Instruction = CenterDefenceInstructionHiddenField.Value;
                Player.PreferredAction = CenterDefencePreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (RightCenterDefencePlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = RightCenterDefencePlayerIdHiddenField.Value;
                Player.Position = "5";
                Player.Instruction = RightCenterDefenceInstructionHiddenField.Value;
                Player.PreferredAction = RightCenterDefencePreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (RightDefencePlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = RightDefencePlayerIdHiddenField.Value;
                Player.Position = "6";
                Player.Instruction = RightDefenceInstructionHiddenField.Value;
                Player.PreferredAction = RightDefencePreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (LeftMidfieldPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = LeftMidfieldPlayerIdHiddenField.Value;
                Player.Position = "7";
                Player.Instruction = LeftMidfieldInstructionHiddenField.Value;
                Player.PreferredAction = LeftMidfieldPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (LeftCenterMidfieldPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = LeftCenterMidfieldPlayerIdHiddenField.Value;
                Player.Position = "8";
                Player.Instruction = LeftCenterMidfieldInstructionHiddenField.Value;
                Player.PreferredAction = LeftCenterMidfieldPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (CenterMidfieldPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = CenterMidfieldPlayerIdHiddenField.Value;
                Player.Position = "9";
                Player.Instruction = CenterMidfieldInstructionHiddenField.Value;
                Player.PreferredAction = CenterMidfieldPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (RightCenterMidfieldPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = RightCenterMidfieldPlayerIdHiddenField.Value;
                Player.Position = "10";
                Player.Instruction = RightCenterMidfieldInstructionHiddenField.Value;
                Player.PreferredAction = RightCenterMidfieldPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (RightMidfieldPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = RightMidfieldPlayerIdHiddenField.Value;
                Player.Position = "11";
                Player.Instruction = RightMidfieldInstructionHiddenField.Value;
                Player.PreferredAction = RightMidfieldPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
            if (LeftAttackPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = LeftAttackPlayerIdHiddenField.Value;
                Player.Position = "12";
                Player.Instruction = LeftAttackInstructionHiddenField.Value;
                Player.PreferredAction = LeftAttackPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }

            if (LeftCenterAttackPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = LeftCenterAttackPlayerIdHiddenField.Value;
                Player.Position = "13";
                Player.Instruction = LeftCenterAttackInstructionHiddenField.Value;
                Player.PreferredAction = LeftCenterAttackPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }

            if (CenterAttackPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = CenterAttackPlayerIdHiddenField.Value;
                Player.Position = "14";
                Player.Instruction = CenterAttackInstructionHiddenField.Value;
                Player.PreferredAction = CenterAttackPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }

            if (RightCenterAttackPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = RightCenterAttackPlayerIdHiddenField.Value;
                Player.Position = "15";
                Player.Instruction = RightCenterAttackInstructionHiddenField.Value;
                Player.PreferredAction = RightCenterAttackPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }

            if (RightAttackPlayerIdHiddenField.Value != "0")
            {
                Player = new PlayerInMatch();
                Player.Id = RightAttackPlayerIdHiddenField.Value;
                Player.Position = "16";
                Player.Instruction = RightAttackInstructionHiddenField.Value;
                Player.PreferredAction = RightAttackPreferredActionHiddenField.Value;
                Players.AddFirst(Player);
            }
        
            return Players;
        }

        private LinkedList<SubPlayer> GetSelectedSubPlayers()
        {
            SubPlayer Player;
            LinkedList<SubPlayer> Players = new LinkedList<SubPlayer>();

            if (Sub1PlayerIdHiddenField.Value != "0")
            {
                Player = new SubPlayer();
                Player.Id = Sub1PlayerIdHiddenField.Value;
                Player.Position = Sub1PositionsRadioButtonList.SelectedValue;
                Players.AddFirst(Player);
            }

            if (Sub2PlayerIdHiddenField.Value != "0")
            {
                Player = new SubPlayer();
                Player.Id = Sub2PlayerIdHiddenField.Value;
                Player.Position = Sub2PositionsRadioButtonList.SelectedValue;
                Players.AddFirst(Player);
            }

            if (Sub3PlayerIdHiddenField.Value != "0")
            {
                Player = new SubPlayer();
                Player.Id = Sub3PlayerIdHiddenField.Value;
                Player.Position = Sub3PositionsRadioButtonList.SelectedValue;
                Players.AddFirst(Player);
            }
            if (Sub4PlayerIdHiddenField.Value != "0")
            {
                Player = new SubPlayer();
                Player.Id = Sub4PlayerIdHiddenField.Value;
                Player.Position = Sub4PositionsRadioButtonList.SelectedValue;
                Players.AddFirst(Player);
            }
            if (Sub5PlayerIdHiddenField.Value != "0")
            {
                Player = new SubPlayer();
                Player.Id = Sub5PlayerIdHiddenField.Value;
                Player.Position = Sub5PositionsRadioButtonList.SelectedValue;
                Players.AddFirst(Player);
            }

            return Players;
        }

        private void SubmitSubstitutions()
        {
            // Clear all current instructions
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                SqlCommand cmd1 = new SqlCommand("Nivdal_DeleteAllSubstitutionInstructionsForMatch", conn);
                cmd1.CommandType = CommandType.StoredProcedure;

                cmd1.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                cmd1.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                cmd1.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));
                SqlParameter Answer = new SqlParameter("@Answer", SqlDbType.NVarChar, 32);
                Answer.Direction = ParameterDirection.Output;
                cmd1.Parameters.Add(Answer);

                try
                {
                    conn.Open();
                    cmd1.ExecuteNonQuery();
                }
                catch (Exception err) { DebugLabel.Text = err.Message; }
                finally { conn.Close(); }


                // submit the substitutions one by one. This is the ugliest code I've ever wrote.
                // But for some reason "Find control" did not work, so I have no othe ideas for now...
                // combining JS and Listview would be the best way. But this is beyond my abilities too...
                SqlCommand cmd = new SqlCommand("Nivdal_AddSubstitutionInstruction", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                // Sub1
                if (Sub1TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 1));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub1PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub1PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub1TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub1TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub1ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub1ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub1NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub1NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub1NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub1NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub1NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub1PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub1PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }

                }

                // sub2
                if (Sub2TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 2));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub2PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub2PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub2TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub2TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub2ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub2ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub2NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub2NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub2NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub2NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub2NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub2PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub2PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }

                // sub3
                if (Sub3TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 3));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub3PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub3PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub3TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub3TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub3ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub3ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub3NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub3NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub3NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub3NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub3NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub3PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub3PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub4
                if (Sub4TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 4));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub4PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub4PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub4TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub4TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub4ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub4ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub4NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub4NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub4NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub4NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub4NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub4PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub4PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub5
                if (Sub5TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 5));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub5PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub5PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub5TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub5TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub5ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub5ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub5NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub5NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub5NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub5NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub5NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub5PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub5PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub6
                if (Sub6TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 6));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub6PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub6PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub6TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub6TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub6ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub6ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub6NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub6NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub6NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub6NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub6NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub6PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub6PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub7
                if (Sub7TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 7));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub7PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub7PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub7TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub7TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub7ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub7ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub7NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub7NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub7NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub7NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub7NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub7PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub7PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub8
                if (Sub8TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 8));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub8PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub8PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub8TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub8TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub8ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub8ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub8NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub8NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub8NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub8NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub8NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub8PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub8PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub9
                if (Sub9TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 9));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub9PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub9PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub9TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub9TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub9ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub9ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub9NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub9NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub9NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub9NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub9NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub9PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub9PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub10
                if (Sub10TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 10));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub10PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub10PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub10TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub10TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub10ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub10ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub10NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub10NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub10NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub10NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub10NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub10PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub10PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub11
                if (Sub11TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 11));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub11PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub11PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub11TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub11TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub11ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub11ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub11NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub11NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub11NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub11NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub11NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub11PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub11PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub12
                if (Sub12TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 12));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub12PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub12PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub12TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub12TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub12ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub12ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub12NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub12NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub12NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub12NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub12NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub12PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub12PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub13
                if (Sub13TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 13));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub13PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub13PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub13TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub13TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub13ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub13ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub13NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub13NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub13NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub13NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub13NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub13PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub13PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub14
                if (Sub14TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 14));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub14PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub14PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub14TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub14TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub14ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub14ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub14NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub14NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub14NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub14NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub14NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub14PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub14PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub15
                if (Sub15TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 15));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub15PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub15PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub15TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub15TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub15ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub15ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub15NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub15NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub15NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub15NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub15NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub15PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub15PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub16
                if (Sub16TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 16));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub16PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub16PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub16TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub16TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub16ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub16ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub16NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub16NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub16NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub16NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub16NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub16PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub16PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub17
                if (Sub17TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 17));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub17PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub17PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub17TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub17TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub17ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub17ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub17NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub17NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub17NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub17NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub17NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub17PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub17PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub18
                if (Sub18TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 18));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub18PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub18PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub18TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub18TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub18ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub18ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub18NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub18NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub18NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub18NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub18NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub18PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub18PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub19
                if (Sub19TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 19));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub19PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub19PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub19TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub19TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub19ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub19ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub19NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub19NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub19NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub19NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub19NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub19PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub19PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
                // sub20
                if (Sub20TypeHiddenField.Value != "0")
                {
                    cmd.Parameters.Add(new SqlParameter("@MatchId", MatchIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@TeamId", TeamIdHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Order", 20));
                    cmd.Parameters.Add(new SqlParameter("@PlayerIn", Sub20PlayerInHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PlayerOut", Sub20PlayerOutHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@StartTime", Sub20TimeMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@EndTime", Sub20TimeMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMin", Sub20ScoreMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@GoalsMax", Sub20ScoreMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPosition", Sub20NewPlayerPositionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerInstruction", Sub20NewPlayerInstructionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewPlayerPreferredAction", Sub20NewPlayerPreferredActionHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAggressiveness", Sub20NewTeamAggressivenessHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@NewTeamAttitude", Sub20NewTeamAttitudeHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMin", Sub20PossessionMinHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@PossessionMax", Sub20PossessionMaxHiddenField.Value));
                    cmd.Parameters.Add(new SqlParameter("@Language", LanguageHiddenField.Value));

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Parameters.Clear();
                    }
                }
            }
        }

        protected void SubmitOrders(object sender, EventArgs e)
        {
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            //PTSEL.Text = OKSubmit.ToString();
            //first check Limitation 4
            string UserId = UserIdHiddenField.Value;
            string MatchId = MatchIdHiddenField.Value;
            string Answer;
            string Status;
            int index;
            LinkedListNode<PlayerInMatch> OutPlayer;
            LinkedListNode<SubPlayer> SubPlayer;
            string ParamName;

            LinkedList<PlayerInMatch> OutPlayers = GetSelectedOutfieldPlayers();
            LinkedList<SubPlayer> SubPlayers = GetSelectedSubPlayers();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("Nivdal_AssignMatchOrders", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("Answer", SqlDbType.NVarChar, 64);
                cmd.Parameters["Answer"].Direction = ParameterDirection.Output;
                cmd.Parameters.Add("Status", SqlDbType.Decimal, 1);
                cmd.Parameters["Status"].Direction = ParameterDirection.Output;

                //@UserId
                cmd.Parameters.Add("UserId", SqlDbType.NVarChar);
                cmd.Parameters["UserId"].Direction = ParameterDirection.Input;
                cmd.Parameters["UserId"].Value = UserId;

                // Language
                cmd.Parameters.Add("Language", SqlDbType.Decimal, 3);
                cmd.Parameters["Language"].Direction = ParameterDirection.Input;
                cmd.Parameters["Language"].Value = LanguageHiddenField.Value;

                //@MatchId
                cmd.Parameters.Add("MatchId", SqlDbType.Decimal, 12);
                cmd.Parameters["MatchId"].Direction = ParameterDirection.Input;
                cmd.Parameters["MatchId"].Value = MatchId;

                // Default
                cmd.Parameters.Add("Default", SqlDbType.Bit);
                cmd.Parameters["Default"].Direction = ParameterDirection.Input;
                cmd.Parameters["Default"].Value = SaveAsDefaultCheckBox.Checked;

                cmd.Parameters.Add("DefaultType", SqlDbType.Decimal, 2);
                cmd.Parameters["DefaultType"].Direction = ParameterDirection.Input;
                cmd.Parameters["DefaultType"].Value = SaveDefaultTypeDDL.SelectedValue;
                
                //TeamAggressiveness
                cmd.Parameters.Add("TeamAggressiveness", SqlDbType.Decimal, 2);
                cmd.Parameters["TeamAggressiveness"].Direction = ParameterDirection.Input;
                cmd.Parameters["TeamAggressiveness"].Value = TeamAggressivenessDropDownList.SelectedValue;

                // TeamAttitude
                cmd.Parameters.Add("TeamAttitude", SqlDbType.Decimal, 2);
                cmd.Parameters["TeamAttitude"].Direction = ParameterDirection.Input;
                cmd.Parameters["TeamAttitude"].Value = TeamAttitudeDropDownList.SelectedValue;

                // Captain
                cmd.Parameters.Add("Captain", SqlDbType.Decimal, 12);
                cmd.Parameters["Captain"].Direction = ParameterDirection.Input;
                cmd.Parameters["Captain"].Value = CaptainHiddenField.Value;

                // SetPiecesTaker
                cmd.Parameters.Add("SetPiecesTaker", SqlDbType.Decimal, 12);
                cmd.Parameters["SetPiecesTaker"].Direction = ParameterDirection.Input;
                cmd.Parameters["SetPiecesTaker"].Value = SetPiecesTakerHiddenField.Value;


                // Players
                index = 1;
                OutPlayer = OutPlayers.First;
                while (OutPlayer != null)
                {
                    ParamName = "Player" + index.ToString();

                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 12);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = OutPlayer.Value.Id;

                    ParamName = "PositionPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = OutPlayer.Value.Position;

                    ParamName = "InstructionPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = OutPlayer.Value.Instruction;

                    ParamName = "AggressivenessPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = TeamAggressivenessDropDownList.SelectedValue;

                    ParamName = "AttitudePlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = TeamAttitudeDropDownList.SelectedValue;

                    ParamName = "PreferredActionPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = OutPlayer.Value.PreferredAction;

                    OutPlayer = OutPlayer.Next;
                    index++;
                }
                // complete to 11 players with zeroes
                while (index <= 11)
                {
                    ParamName = "Player" + index.ToString();

                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 12);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    ParamName = "PositionPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    ParamName = "InstructionPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    ParamName = "AggressivenessPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    ParamName = "AttitudePlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    ParamName = "PreferredActionPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    index++;
                }
                SubPlayer = SubPlayers.First;
                // Sub players parameters
                while (SubPlayer != null)
                {
                    ParamName = "Player" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 12);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = SubPlayer.Value.Id;

                    ParamName = "PositionPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = SubPlayer.Value.Position;


                    ParamName = "AggressivenessPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = TeamAggressivenessDropDownList.SelectedValue;

                    ParamName = "AttitudePlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = TeamAttitudeDropDownList.SelectedValue;

                    index++;
                    SubPlayer = SubPlayer.Next;
                }

                // complete missing subs with zeroes
                while (index <= 16)
                {
                    ParamName = "Player" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 12);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    ParamName = "PositionPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    ParamName = "AggressivenessPlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    ParamName = "AttitudePlayer" + index.ToString();
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 2);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    cmd.Parameters[ParamName].Value = "0";

                    index++;
                }

                // Penalty takers. 
                index = 1;
                while (index <= 11)
                {
                    ParamName = "Penalty" + index.ToString() + "Taker";
                    cmd.Parameters.Add(ParamName, SqlDbType.Decimal, 12);
                    cmd.Parameters[ParamName].Direction = ParameterDirection.Input;
                    switch (index)
                    {
                        case 1:
                            cmd.Parameters[ParamName].Value = PenaltyTaker1HiddenField.Value;
                            break;
                        case 2:
                            cmd.Parameters[ParamName].Value = PenaltyTaker2HiddenField.Value;
                            break;
                        case 3:
                            cmd.Parameters[ParamName].Value = PenaltyTaker3HiddenField.Value;
                            break;
                        case 4:
                            cmd.Parameters[ParamName].Value = PenaltyTaker4HiddenField.Value;
                            break;
                        case 5:
                            cmd.Parameters[ParamName].Value = PenaltyTaker5HiddenField.Value;
                            break;
                        case 6:
                            cmd.Parameters[ParamName].Value = PenaltyTaker6HiddenField.Value;
                            break;
                        case 7:
                            cmd.Parameters[ParamName].Value = PenaltyTaker7HiddenField.Value;
                            break;
                        case 8:
                            cmd.Parameters[ParamName].Value = PenaltyTaker8HiddenField.Value;
                            break;
                        case 9:
                            cmd.Parameters[ParamName].Value = PenaltyTaker9HiddenField.Value;
                            break;
                        case 10:
                            cmd.Parameters[ParamName].Value = PenaltyTaker10HiddenField.Value;
                            break;
                        case 11:
                            cmd.Parameters[ParamName].Value = PenaltyTaker11HiddenField.Value;
                            break;
                    }

                    index++;
                }

                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    Answer = cmd.Parameters["Answer"].Value.ToString();
                    Status = cmd.Parameters["Status"].Value.ToString();

                    if (Status != "0")
                    {
                        // this should not happen - javascript validation should take care of everything.
                        DebugLabel.Text = Answer;
                    }
                }
                finally
                {
                    conn.Close();
                }
            }
            SubmitSubstitutions();
            bool IsNTMatch = GND.ReadNivdalBoolData("MatchId", "Nivdal_IsMatchNT", MatchIdHiddenField.Value);
            if (IsNTMatch)
                Response.Redirect("ListOfTeamMatches.aspx?ConfirmNote=" + Answer + "&NationalTeam=yes");
            else
                Response.Redirect("ListOfTeamMatches.aspx?ConfirmNote=" + Answer);
        }
        #endregion

        protected string InjuryIconName(object Injury)
        {
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            return GND.InjuryIconName(Injury);
        }

    }
}